package dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;

import metier.Artiste;
import metier.Spectacle;

public class DaoArtiste 
{
	public static Vector <Artiste> getLesArtistes () throws ClassNotFoundException, SQLException
	{
		String chaine = "jdbc:mysql://localhost/";
		Statement stLienBd = null;
		ResultSet res = null;
		String req;
		Connection connec;
		Vector <Artiste> lesArtistes;
		Artiste lartiste;
		connec = MySqlConnection.getConnection(chaine + "mlr1", "root", "");
		stLienBd = connec.createStatement();
		lesArtistes = new Vector <Artiste>();
		try
		{
			
			req = "select * from artiste";
			res = stLienBd.executeQuery(req);
			while (res.next())
			{
				
				lartiste = new Artiste (res.getInt(1), res.getString(2), res.getString(3), res.getString(4), );
				lesArtistes.add(lartiste);
			}
			res.close();
			connec.close();
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
		}
		return lesArtistes;
	}
}
